{
 "cells": [
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "\n",
    "# 利用groupby对数据进行合并操作，常用于对时间序列合并，例如对时间间隔是日的求月平均或者对几年求年平均"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import xarray as xr\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "# 读取数据\n",
    "# dataframe形式的数据\n",
    "df =pd.read_csv('../pythonhomework6csv.csv')\n",
    "# dataset/dataarray形式的数据\n",
    "ds =xr.open_dataset(\"D:/WORKcode/DuanQiQiHou/data/hgt.mon.mean.nc\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Unnamed: 0</th>\n",
       "      <th>year</th>\n",
       "      <th>month</th>\n",
       "      <th>day</th>\n",
       "      <th>RMM1</th>\n",
       "      <th>RMM2</th>\n",
       "      <th>phase</th>\n",
       "      <th>amplitude</th>\n",
       "      <th>final_values</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>1974</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>1.634470</td>\n",
       "      <td>1.203040</td>\n",
       "      <td>5</td>\n",
       "      <td>2.029480</td>\n",
       "      <td>Final_value:__OLR_&amp;_NCEP_winds</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>1974</td>\n",
       "      <td>6</td>\n",
       "      <td>2</td>\n",
       "      <td>1.602890</td>\n",
       "      <td>1.015120</td>\n",
       "      <td>5</td>\n",
       "      <td>1.897290</td>\n",
       "      <td>Final_value:__OLR_&amp;_NCEP_winds</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>1974</td>\n",
       "      <td>6</td>\n",
       "      <td>3</td>\n",
       "      <td>1.516250</td>\n",
       "      <td>1.085510</td>\n",
       "      <td>5</td>\n",
       "      <td>1.864760</td>\n",
       "      <td>Final_value:__OLR_&amp;_NCEP_winds</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>1974</td>\n",
       "      <td>6</td>\n",
       "      <td>4</td>\n",
       "      <td>1.509810</td>\n",
       "      <td>1.035730</td>\n",
       "      <td>5</td>\n",
       "      <td>1.830920</td>\n",
       "      <td>Final_value:__OLR_&amp;_NCEP_winds</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>1974</td>\n",
       "      <td>6</td>\n",
       "      <td>5</td>\n",
       "      <td>1.559060</td>\n",
       "      <td>1.305180</td>\n",
       "      <td>5</td>\n",
       "      <td>2.033260</td>\n",
       "      <td>Final_value:__OLR_&amp;_NCEP_winds</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17460</th>\n",
       "      <td>17460</td>\n",
       "      <td>2022</td>\n",
       "      <td>3</td>\n",
       "      <td>21</td>\n",
       "      <td>1.058647</td>\n",
       "      <td>-1.269627</td>\n",
       "      <td>3</td>\n",
       "      <td>1.653084</td>\n",
       "      <td>Prelim_value:_OLR_&amp;_ACCESS_wind</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17461</th>\n",
       "      <td>17461</td>\n",
       "      <td>2022</td>\n",
       "      <td>3</td>\n",
       "      <td>22</td>\n",
       "      <td>1.039455</td>\n",
       "      <td>-0.817596</td>\n",
       "      <td>4</td>\n",
       "      <td>1.322471</td>\n",
       "      <td>Prelim_value:_OLR_&amp;_ACCESS_wind</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17462</th>\n",
       "      <td>17462</td>\n",
       "      <td>2022</td>\n",
       "      <td>3</td>\n",
       "      <td>23</td>\n",
       "      <td>0.981937</td>\n",
       "      <td>-0.722337</td>\n",
       "      <td>4</td>\n",
       "      <td>1.219004</td>\n",
       "      <td>Prelim_value:_OLR_&amp;_ACCESS_wind</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17463</th>\n",
       "      <td>17463</td>\n",
       "      <td>2022</td>\n",
       "      <td>3</td>\n",
       "      <td>24</td>\n",
       "      <td>0.900615</td>\n",
       "      <td>-0.630580</td>\n",
       "      <td>4</td>\n",
       "      <td>1.099426</td>\n",
       "      <td>Prelim_value:_OLR_&amp;_ACCESS_wind</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17464</th>\n",
       "      <td>17464</td>\n",
       "      <td>2022</td>\n",
       "      <td>3</td>\n",
       "      <td>25</td>\n",
       "      <td>0.488374</td>\n",
       "      <td>-0.406457</td>\n",
       "      <td>4</td>\n",
       "      <td>0.635386</td>\n",
       "      <td>Prelim_value:_OLR_&amp;_ACCESS_wind</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>17465 rows × 9 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       Unnamed: 0  year  month  day      RMM1      RMM2  phase  amplitude  \\\n",
       "0               0  1974      6    1  1.634470  1.203040      5   2.029480   \n",
       "1               1  1974      6    2  1.602890  1.015120      5   1.897290   \n",
       "2               2  1974      6    3  1.516250  1.085510      5   1.864760   \n",
       "3               3  1974      6    4  1.509810  1.035730      5   1.830920   \n",
       "4               4  1974      6    5  1.559060  1.305180      5   2.033260   \n",
       "...           ...   ...    ...  ...       ...       ...    ...        ...   \n",
       "17460       17460  2022      3   21  1.058647 -1.269627      3   1.653084   \n",
       "17461       17461  2022      3   22  1.039455 -0.817596      4   1.322471   \n",
       "17462       17462  2022      3   23  0.981937 -0.722337      4   1.219004   \n",
       "17463       17463  2022      3   24  0.900615 -0.630580      4   1.099426   \n",
       "17464       17464  2022      3   25  0.488374 -0.406457      4   0.635386   \n",
       "\n",
       "                          final_values  \n",
       "0       Final_value:__OLR_&_NCEP_winds  \n",
       "1       Final_value:__OLR_&_NCEP_winds  \n",
       "2       Final_value:__OLR_&_NCEP_winds  \n",
       "3       Final_value:__OLR_&_NCEP_winds  \n",
       "4       Final_value:__OLR_&_NCEP_winds  \n",
       "...                                ...  \n",
       "17460  Prelim_value:_OLR_&_ACCESS_wind  \n",
       "17461  Prelim_value:_OLR_&_ACCESS_wind  \n",
       "17462  Prelim_value:_OLR_&_ACCESS_wind  \n",
       "17463  Prelim_value:_OLR_&_ACCESS_wind  \n",
       "17464  Prelim_value:_OLR_&_ACCESS_wind  \n",
       "\n",
       "[17465 rows x 9 columns]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><svg style=\"position: absolute; width: 0; height: 0; overflow: hidden\">\n",
       "<defs>\n",
       "<symbol id=\"icon-database\" viewBox=\"0 0 32 32\">\n",
       "<path d=\"M16 0c-8.837 0-16 2.239-16 5v4c0 2.761 7.163 5 16 5s16-2.239 16-5v-4c0-2.761-7.163-5-16-5z\"></path>\n",
       "<path d=\"M16 17c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
       "<path d=\"M16 26c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
       "</symbol>\n",
       "<symbol id=\"icon-file-text2\" viewBox=\"0 0 32 32\">\n",
       "<path d=\"M28.681 7.159c-0.694-0.947-1.662-2.053-2.724-3.116s-2.169-2.030-3.116-2.724c-1.612-1.182-2.393-1.319-2.841-1.319h-15.5c-1.378 0-2.5 1.121-2.5 2.5v27c0 1.378 1.122 2.5 2.5 2.5h23c1.378 0 2.5-1.122 2.5-2.5v-19.5c0-0.448-0.137-1.23-1.319-2.841zM24.543 5.457c0.959 0.959 1.712 1.825 2.268 2.543h-4.811v-4.811c0.718 0.556 1.584 1.309 2.543 2.268zM28 29.5c0 0.271-0.229 0.5-0.5 0.5h-23c-0.271 0-0.5-0.229-0.5-0.5v-27c0-0.271 0.229-0.5 0.5-0.5 0 0 15.499-0 15.5 0v7c0 0.552 0.448 1 1 1h7v19.5z\"></path>\n",
       "<path d=\"M23 26h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
       "<path d=\"M23 22h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
       "<path d=\"M23 18h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
       "</symbol>\n",
       "</defs>\n",
       "</svg>\n",
       "<style>/* CSS stylesheet for displaying xarray objects in jupyterlab.\n",
       " *\n",
       " */\n",
       "\n",
       ":root {\n",
       "  --xr-font-color0: var(--jp-content-font-color0, rgba(0, 0, 0, 1));\n",
       "  --xr-font-color2: var(--jp-content-font-color2, rgba(0, 0, 0, 0.54));\n",
       "  --xr-font-color3: var(--jp-content-font-color3, rgba(0, 0, 0, 0.38));\n",
       "  --xr-border-color: var(--jp-border-color2, #e0e0e0);\n",
       "  --xr-disabled-color: var(--jp-layout-color3, #bdbdbd);\n",
       "  --xr-background-color: var(--jp-layout-color0, white);\n",
       "  --xr-background-color-row-even: var(--jp-layout-color1, white);\n",
       "  --xr-background-color-row-odd: var(--jp-layout-color2, #eeeeee);\n",
       "}\n",
       "\n",
       "html[theme=dark],\n",
       "body.vscode-dark {\n",
       "  --xr-font-color0: rgba(255, 255, 255, 1);\n",
       "  --xr-font-color2: rgba(255, 255, 255, 0.54);\n",
       "  --xr-font-color3: rgba(255, 255, 255, 0.38);\n",
       "  --xr-border-color: #1F1F1F;\n",
       "  --xr-disabled-color: #515151;\n",
       "  --xr-background-color: #111111;\n",
       "  --xr-background-color-row-even: #111111;\n",
       "  --xr-background-color-row-odd: #313131;\n",
       "}\n",
       "\n",
       ".xr-wrap {\n",
       "  display: block !important;\n",
       "  min-width: 300px;\n",
       "  max-width: 700px;\n",
       "}\n",
       "\n",
       ".xr-text-repr-fallback {\n",
       "  /* fallback to plain text repr when CSS is not injected (untrusted notebook) */\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-header {\n",
       "  padding-top: 6px;\n",
       "  padding-bottom: 6px;\n",
       "  margin-bottom: 4px;\n",
       "  border-bottom: solid 1px var(--xr-border-color);\n",
       "}\n",
       "\n",
       ".xr-header > div,\n",
       ".xr-header > ul {\n",
       "  display: inline;\n",
       "  margin-top: 0;\n",
       "  margin-bottom: 0;\n",
       "}\n",
       "\n",
       ".xr-obj-type,\n",
       ".xr-array-name {\n",
       "  margin-left: 2px;\n",
       "  margin-right: 10px;\n",
       "}\n",
       "\n",
       ".xr-obj-type {\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-sections {\n",
       "  padding-left: 0 !important;\n",
       "  display: grid;\n",
       "  grid-template-columns: 150px auto auto 1fr 20px 20px;\n",
       "}\n",
       "\n",
       ".xr-section-item {\n",
       "  display: contents;\n",
       "}\n",
       "\n",
       ".xr-section-item input {\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-section-item input + label {\n",
       "  color: var(--xr-disabled-color);\n",
       "}\n",
       "\n",
       ".xr-section-item input:enabled + label {\n",
       "  cursor: pointer;\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-section-item input:enabled + label:hover {\n",
       "  color: var(--xr-font-color0);\n",
       "}\n",
       "\n",
       ".xr-section-summary {\n",
       "  grid-column: 1;\n",
       "  color: var(--xr-font-color2);\n",
       "  font-weight: 500;\n",
       "}\n",
       "\n",
       ".xr-section-summary > span {\n",
       "  display: inline-block;\n",
       "  padding-left: 0.5em;\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:disabled + label {\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-section-summary-in + label:before {\n",
       "  display: inline-block;\n",
       "  content: '►';\n",
       "  font-size: 11px;\n",
       "  width: 15px;\n",
       "  text-align: center;\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:disabled + label:before {\n",
       "  color: var(--xr-disabled-color);\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:checked + label:before {\n",
       "  content: '▼';\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:checked + label > span {\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-section-summary,\n",
       ".xr-section-inline-details {\n",
       "  padding-top: 4px;\n",
       "  padding-bottom: 4px;\n",
       "}\n",
       "\n",
       ".xr-section-inline-details {\n",
       "  grid-column: 2 / -1;\n",
       "}\n",
       "\n",
       ".xr-section-details {\n",
       "  display: none;\n",
       "  grid-column: 1 / -1;\n",
       "  margin-bottom: 5px;\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:checked ~ .xr-section-details {\n",
       "  display: contents;\n",
       "}\n",
       "\n",
       ".xr-array-wrap {\n",
       "  grid-column: 1 / -1;\n",
       "  display: grid;\n",
       "  grid-template-columns: 20px auto;\n",
       "}\n",
       "\n",
       ".xr-array-wrap > label {\n",
       "  grid-column: 1;\n",
       "  vertical-align: top;\n",
       "}\n",
       "\n",
       ".xr-preview {\n",
       "  color: var(--xr-font-color3);\n",
       "}\n",
       "\n",
       ".xr-array-preview,\n",
       ".xr-array-data {\n",
       "  padding: 0 5px !important;\n",
       "  grid-column: 2;\n",
       "}\n",
       "\n",
       ".xr-array-data,\n",
       ".xr-array-in:checked ~ .xr-array-preview {\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-array-in:checked ~ .xr-array-data,\n",
       ".xr-array-preview {\n",
       "  display: inline-block;\n",
       "}\n",
       "\n",
       ".xr-dim-list {\n",
       "  display: inline-block !important;\n",
       "  list-style: none;\n",
       "  padding: 0 !important;\n",
       "  margin: 0;\n",
       "}\n",
       "\n",
       ".xr-dim-list li {\n",
       "  display: inline-block;\n",
       "  padding: 0;\n",
       "  margin: 0;\n",
       "}\n",
       "\n",
       ".xr-dim-list:before {\n",
       "  content: '(';\n",
       "}\n",
       "\n",
       ".xr-dim-list:after {\n",
       "  content: ')';\n",
       "}\n",
       "\n",
       ".xr-dim-list li:not(:last-child):after {\n",
       "  content: ',';\n",
       "  padding-right: 5px;\n",
       "}\n",
       "\n",
       ".xr-has-index {\n",
       "  font-weight: bold;\n",
       "}\n",
       "\n",
       ".xr-var-list,\n",
       ".xr-var-item {\n",
       "  display: contents;\n",
       "}\n",
       "\n",
       ".xr-var-item > div,\n",
       ".xr-var-item label,\n",
       ".xr-var-item > .xr-var-name span {\n",
       "  background-color: var(--xr-background-color-row-even);\n",
       "  margin-bottom: 0;\n",
       "}\n",
       "\n",
       ".xr-var-item > .xr-var-name:hover span {\n",
       "  padding-right: 5px;\n",
       "}\n",
       "\n",
       ".xr-var-list > li:nth-child(odd) > div,\n",
       ".xr-var-list > li:nth-child(odd) > label,\n",
       ".xr-var-list > li:nth-child(odd) > .xr-var-name span {\n",
       "  background-color: var(--xr-background-color-row-odd);\n",
       "}\n",
       "\n",
       ".xr-var-name {\n",
       "  grid-column: 1;\n",
       "}\n",
       "\n",
       ".xr-var-dims {\n",
       "  grid-column: 2;\n",
       "}\n",
       "\n",
       ".xr-var-dtype {\n",
       "  grid-column: 3;\n",
       "  text-align: right;\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-var-preview {\n",
       "  grid-column: 4;\n",
       "}\n",
       "\n",
       ".xr-var-name,\n",
       ".xr-var-dims,\n",
       ".xr-var-dtype,\n",
       ".xr-preview,\n",
       ".xr-attrs dt {\n",
       "  white-space: nowrap;\n",
       "  overflow: hidden;\n",
       "  text-overflow: ellipsis;\n",
       "  padding-right: 10px;\n",
       "}\n",
       "\n",
       ".xr-var-name:hover,\n",
       ".xr-var-dims:hover,\n",
       ".xr-var-dtype:hover,\n",
       ".xr-attrs dt:hover {\n",
       "  overflow: visible;\n",
       "  width: auto;\n",
       "  z-index: 1;\n",
       "}\n",
       "\n",
       ".xr-var-attrs,\n",
       ".xr-var-data {\n",
       "  display: none;\n",
       "  background-color: var(--xr-background-color) !important;\n",
       "  padding-bottom: 5px !important;\n",
       "}\n",
       "\n",
       ".xr-var-attrs-in:checked ~ .xr-var-attrs,\n",
       ".xr-var-data-in:checked ~ .xr-var-data {\n",
       "  display: block;\n",
       "}\n",
       "\n",
       ".xr-var-data > table {\n",
       "  float: right;\n",
       "}\n",
       "\n",
       ".xr-var-name span,\n",
       ".xr-var-data,\n",
       ".xr-attrs {\n",
       "  padding-left: 25px !important;\n",
       "}\n",
       "\n",
       ".xr-attrs,\n",
       ".xr-var-attrs,\n",
       ".xr-var-data {\n",
       "  grid-column: 1 / -1;\n",
       "}\n",
       "\n",
       "dl.xr-attrs {\n",
       "  padding: 0;\n",
       "  margin: 0;\n",
       "  display: grid;\n",
       "  grid-template-columns: 125px auto;\n",
       "}\n",
       "\n",
       ".xr-attrs dt,\n",
       ".xr-attrs dd {\n",
       "  padding: 0;\n",
       "  margin: 0;\n",
       "  float: left;\n",
       "  padding-right: 10px;\n",
       "  width: auto;\n",
       "}\n",
       "\n",
       ".xr-attrs dt {\n",
       "  font-weight: normal;\n",
       "  grid-column: 1;\n",
       "}\n",
       "\n",
       ".xr-attrs dt:hover span {\n",
       "  display: inline-block;\n",
       "  background: var(--xr-background-color);\n",
       "  padding-right: 10px;\n",
       "}\n",
       "\n",
       ".xr-attrs dd {\n",
       "  grid-column: 2;\n",
       "  white-space: pre-wrap;\n",
       "  word-break: break-all;\n",
       "}\n",
       "\n",
       ".xr-icon-database,\n",
       ".xr-icon-file-text2 {\n",
       "  display: inline-block;\n",
       "  vertical-align: middle;\n",
       "  width: 1em;\n",
       "  height: 1.5em !important;\n",
       "  stroke-width: 0;\n",
       "  stroke: currentColor;\n",
       "  fill: currentColor;\n",
       "}\n",
       "</style><pre class='xr-text-repr-fallback'>&lt;xarray.Dataset&gt;\n",
       "Dimensions:  (level: 17, lat: 73, lon: 144, time: 855)\n",
       "Coordinates:\n",
       "  * level    (level) float32 1e+03 925.0 850.0 700.0 ... 50.0 30.0 20.0 10.0\n",
       "  * lat      (lat) float32 90.0 87.5 85.0 82.5 80.0 ... -82.5 -85.0 -87.5 -90.0\n",
       "  * lon      (lon) float32 0.0 2.5 5.0 7.5 10.0 ... 350.0 352.5 355.0 357.5\n",
       "  * time     (time) datetime64[ns] 1948-01-01 1948-02-01 ... 2019-03-01\n",
       "Data variables:\n",
       "    hgt      (time, level, lat, lon) float32 ...\n",
       "Attributes:\n",
       "    description:     Data from NCEP initialized reanalysis (4x/day).  These a...\n",
       "    platform:       Model\n",
       "    Conventions:    COARDS\n",
       "    NCO:            20121012\n",
       "    history:        Created by NOAA-CIRES Climate Diagnostics Center (SAC) fr...\n",
       "    title:          monthly mean hgt from the NCEP Reanalysis\n",
       "    References:     http://www.esrl.noaa.gov/psd/data/gridded/data.ncep.reana...\n",
       "    dataset_title:  NCEP-NCAR Reanalysis 1</pre><div class='xr-wrap' style='display:none'><div class='xr-header'><div class='xr-obj-type'>xarray.Dataset</div></div><ul class='xr-sections'><li class='xr-section-item'><input id='section-fe86a075-f5d3-455d-9189-12c67c224465' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-fe86a075-f5d3-455d-9189-12c67c224465' class='xr-section-summary'  title='Expand/collapse section'>Dimensions:</label><div class='xr-section-inline-details'><ul class='xr-dim-list'><li><span class='xr-has-index'>level</span>: 17</li><li><span class='xr-has-index'>lat</span>: 73</li><li><span class='xr-has-index'>lon</span>: 144</li><li><span class='xr-has-index'>time</span>: 855</li></ul></div><div class='xr-section-details'></div></li><li class='xr-section-item'><input id='section-bb0c0317-1923-4a9b-b1e3-8cc2331adfe6' class='xr-section-summary-in' type='checkbox'  checked><label for='section-bb0c0317-1923-4a9b-b1e3-8cc2331adfe6' class='xr-section-summary' >Coordinates: <span>(4)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>level</span></div><div class='xr-var-dims'>(level)</div><div class='xr-var-dtype'>float32</div><div class='xr-var-preview xr-preview'>1e+03 925.0 850.0 ... 20.0 10.0</div><input id='attrs-a02aaf90-f750-43f3-90d7-0f2883f8877b' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-a02aaf90-f750-43f3-90d7-0f2883f8877b' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-c9cc2a86-a7ea-4ff5-a4bd-a48e3dbe5c7c' class='xr-var-data-in' type='checkbox'><label for='data-c9cc2a86-a7ea-4ff5-a4bd-a48e3dbe5c7c' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>units :</span></dt><dd>millibar</dd><dt><span>long_name :</span></dt><dd>Level</dd><dt><span>positive :</span></dt><dd>down</dd><dt><span>GRIB_id :</span></dt><dd>100</dd><dt><span>GRIB_name :</span></dt><dd>hPa</dd><dt><span>actual_range :</span></dt><dd>[1000.   10.]</dd><dt><span>axis :</span></dt><dd>Z</dd></dl></div><div class='xr-var-data'><pre>array([1000.,  925.,  850.,  700.,  600.,  500.,  400.,  300.,  250.,  200.,\n",
       "        150.,  100.,   70.,   50.,   30.,   20.,   10.], dtype=float32)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>lat</span></div><div class='xr-var-dims'>(lat)</div><div class='xr-var-dtype'>float32</div><div class='xr-var-preview xr-preview'>90.0 87.5 85.0 ... -87.5 -90.0</div><input id='attrs-82809c2d-4080-4fcf-8367-ae167f1cc73a' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-82809c2d-4080-4fcf-8367-ae167f1cc73a' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-712dc297-62c2-4dc0-8e04-10713aa50e1b' class='xr-var-data-in' type='checkbox'><label for='data-712dc297-62c2-4dc0-8e04-10713aa50e1b' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>units :</span></dt><dd>degrees_north</dd><dt><span>actual_range :</span></dt><dd>[ 90. -90.]</dd><dt><span>long_name :</span></dt><dd>Latitude</dd><dt><span>standard_name :</span></dt><dd>latitude</dd><dt><span>axis :</span></dt><dd>Y</dd></dl></div><div class='xr-var-data'><pre>array([ 90. ,  87.5,  85. ,  82.5,  80. ,  77.5,  75. ,  72.5,  70. ,  67.5,\n",
       "        65. ,  62.5,  60. ,  57.5,  55. ,  52.5,  50. ,  47.5,  45. ,  42.5,\n",
       "        40. ,  37.5,  35. ,  32.5,  30. ,  27.5,  25. ,  22.5,  20. ,  17.5,\n",
       "        15. ,  12.5,  10. ,   7.5,   5. ,   2.5,   0. ,  -2.5,  -5. ,  -7.5,\n",
       "       -10. , -12.5, -15. , -17.5, -20. , -22.5, -25. , -27.5, -30. , -32.5,\n",
       "       -35. , -37.5, -40. , -42.5, -45. , -47.5, -50. , -52.5, -55. , -57.5,\n",
       "       -60. , -62.5, -65. , -67.5, -70. , -72.5, -75. , -77.5, -80. , -82.5,\n",
       "       -85. , -87.5, -90. ], dtype=float32)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>lon</span></div><div class='xr-var-dims'>(lon)</div><div class='xr-var-dtype'>float32</div><div class='xr-var-preview xr-preview'>0.0 2.5 5.0 ... 352.5 355.0 357.5</div><input id='attrs-dec6e263-0b19-42d4-ba14-64a39d1fc6c9' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-dec6e263-0b19-42d4-ba14-64a39d1fc6c9' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-84719de9-493b-4cf3-ae5c-85ec4c3dc7a7' class='xr-var-data-in' type='checkbox'><label for='data-84719de9-493b-4cf3-ae5c-85ec4c3dc7a7' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>units :</span></dt><dd>degrees_east</dd><dt><span>long_name :</span></dt><dd>Longitude</dd><dt><span>actual_range :</span></dt><dd>[  0.  357.5]</dd><dt><span>standard_name :</span></dt><dd>longitude</dd><dt><span>axis :</span></dt><dd>X</dd></dl></div><div class='xr-var-data'><pre>array([  0. ,   2.5,   5. ,   7.5,  10. ,  12.5,  15. ,  17.5,  20. ,  22.5,\n",
       "        25. ,  27.5,  30. ,  32.5,  35. ,  37.5,  40. ,  42.5,  45. ,  47.5,\n",
       "        50. ,  52.5,  55. ,  57.5,  60. ,  62.5,  65. ,  67.5,  70. ,  72.5,\n",
       "        75. ,  77.5,  80. ,  82.5,  85. ,  87.5,  90. ,  92.5,  95. ,  97.5,\n",
       "       100. , 102.5, 105. , 107.5, 110. , 112.5, 115. , 117.5, 120. , 122.5,\n",
       "       125. , 127.5, 130. , 132.5, 135. , 137.5, 140. , 142.5, 145. , 147.5,\n",
       "       150. , 152.5, 155. , 157.5, 160. , 162.5, 165. , 167.5, 170. , 172.5,\n",
       "       175. , 177.5, 180. , 182.5, 185. , 187.5, 190. , 192.5, 195. , 197.5,\n",
       "       200. , 202.5, 205. , 207.5, 210. , 212.5, 215. , 217.5, 220. , 222.5,\n",
       "       225. , 227.5, 230. , 232.5, 235. , 237.5, 240. , 242.5, 245. , 247.5,\n",
       "       250. , 252.5, 255. , 257.5, 260. , 262.5, 265. , 267.5, 270. , 272.5,\n",
       "       275. , 277.5, 280. , 282.5, 285. , 287.5, 290. , 292.5, 295. , 297.5,\n",
       "       300. , 302.5, 305. , 307.5, 310. , 312.5, 315. , 317.5, 320. , 322.5,\n",
       "       325. , 327.5, 330. , 332.5, 335. , 337.5, 340. , 342.5, 345. , 347.5,\n",
       "       350. , 352.5, 355. , 357.5], dtype=float32)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>time</span></div><div class='xr-var-dims'>(time)</div><div class='xr-var-dtype'>datetime64[ns]</div><div class='xr-var-preview xr-preview'>1948-01-01 ... 2019-03-01</div><input id='attrs-9fd00aa5-68a6-4baf-bb63-0feaf6768a22' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-9fd00aa5-68a6-4baf-bb63-0feaf6768a22' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-0d896d49-4634-4de8-ad4e-c6bab0ca154e' class='xr-var-data-in' type='checkbox'><label for='data-0d896d49-4634-4de8-ad4e-c6bab0ca154e' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>Time</dd><dt><span>delta_t :</span></dt><dd>0000-01-00 00:00:00</dd><dt><span>avg_period :</span></dt><dd>0000-01-00 00:00:00</dd><dt><span>prev_avg_period :</span></dt><dd>0000-00-01 00:00:00</dd><dt><span>standard_name :</span></dt><dd>time</dd><dt><span>axis :</span></dt><dd>T</dd><dt><span>actual_range :</span></dt><dd>[1297320. 1921128.]</dd></dl></div><div class='xr-var-data'><pre>array([&#x27;1948-01-01T00:00:00.000000000&#x27;, &#x27;1948-02-01T00:00:00.000000000&#x27;,\n",
       "       &#x27;1948-03-01T00:00:00.000000000&#x27;, ..., &#x27;2019-01-01T00:00:00.000000000&#x27;,\n",
       "       &#x27;2019-02-01T00:00:00.000000000&#x27;, &#x27;2019-03-01T00:00:00.000000000&#x27;],\n",
       "      dtype=&#x27;datetime64[ns]&#x27;)</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-a86a81a2-8fa3-4e49-9a9d-bd7515fed95c' class='xr-section-summary-in' type='checkbox'  checked><label for='section-a86a81a2-8fa3-4e49-9a9d-bd7515fed95c' class='xr-section-summary' >Data variables: <span>(1)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span>hgt</span></div><div class='xr-var-dims'>(time, level, lat, lon)</div><div class='xr-var-dtype'>float32</div><div class='xr-var-preview xr-preview'>...</div><input id='attrs-718d613e-e87c-4724-9c1c-a628571a8c16' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-718d613e-e87c-4724-9c1c-a628571a8c16' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-e436be81-464f-4421-a5e7-2a180f443cf7' class='xr-var-data-in' type='checkbox'><label for='data-e436be81-464f-4421-a5e7-2a180f443cf7' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>long_name :</span></dt><dd>Monthly mean geopotential height</dd><dt><span>valid_range :</span></dt><dd>[ -700. 35000.]</dd><dt><span>units :</span></dt><dd>m</dd><dt><span>precision :</span></dt><dd>0</dd><dt><span>GRIB_id :</span></dt><dd>7</dd><dt><span>GRIB_name :</span></dt><dd>HGT</dd><dt><span>var_desc :</span></dt><dd>Geopotential height</dd><dt><span>level_desc :</span></dt><dd>Multiple levels</dd><dt><span>statistic :</span></dt><dd>Mean</dd><dt><span>parent_stat :</span></dt><dd>Other</dd><dt><span>dataset :</span></dt><dd>NCEP Reanalysis Derived Products</dd><dt><span>actual_range :</span></dt><dd>[ -354.45834 32321.098  ]</dd></dl></div><div class='xr-var-data'><pre>[152791920 values with dtype=float32]</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-284d59ca-e677-485d-b837-e448f13fa2c6' class='xr-section-summary-in' type='checkbox'  checked><label for='section-284d59ca-e677-485d-b837-e448f13fa2c6' class='xr-section-summary' >Attributes: <span>(8)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><dl class='xr-attrs'><dt><span>description :</span></dt><dd> Data from NCEP initialized reanalysis (4x/day).  These are interpolated to pressure surfaces from model (sigma) surfaces.</dd><dt><span>platform :</span></dt><dd>Model</dd><dt><span>Conventions :</span></dt><dd>COARDS</dd><dt><span>NCO :</span></dt><dd>20121012</dd><dt><span>history :</span></dt><dd>Created by NOAA-CIRES Climate Diagnostics Center (SAC) from the NCEP\n",
       "reanalysis data set on 07/07/97 by calc.mon.mean.year.f using\n",
       "/Datasets/nmc.reanalysis.derived/pressure/hgt.mon.mean.nc\n",
       "from /Datasets/nmc.reanalysis/pressure/hgt.79.nc to hgt.95.nc\n",
       "Converted to chunked, deflated non-packed NetCDF4 2014/09</dd><dt><span>title :</span></dt><dd>monthly mean hgt from the NCEP Reanalysis</dd><dt><span>References :</span></dt><dd>http://www.esrl.noaa.gov/psd/data/gridded/data.ncep.reanalysis.derived.html</dd><dt><span>dataset_title :</span></dt><dd>NCEP-NCAR Reanalysis 1</dd></dl></div></li></ul></div></div>"
      ],
      "text/plain": [
       "<xarray.Dataset>\n",
       "Dimensions:  (level: 17, lat: 73, lon: 144, time: 855)\n",
       "Coordinates:\n",
       "  * level    (level) float32 1e+03 925.0 850.0 700.0 ... 50.0 30.0 20.0 10.0\n",
       "  * lat      (lat) float32 90.0 87.5 85.0 82.5 80.0 ... -82.5 -85.0 -87.5 -90.0\n",
       "  * lon      (lon) float32 0.0 2.5 5.0 7.5 10.0 ... 350.0 352.5 355.0 357.5\n",
       "  * time     (time) datetime64[ns] 1948-01-01 1948-02-01 ... 2019-03-01\n",
       "Data variables:\n",
       "    hgt      (time, level, lat, lon) float32 ...\n",
       "Attributes:\n",
       "    description:     Data from NCEP initialized reanalysis (4x/day).  These a...\n",
       "    platform:       Model\n",
       "    Conventions:    COARDS\n",
       "    NCO:            20121012\n",
       "    history:        Created by NOAA-CIRES Climate Diagnostics Center (SAC) fr...\n",
       "    title:          monthly mean hgt from the NCEP Reanalysis\n",
       "    References:     http://www.esrl.noaa.gov/psd/data/gridded/data.ncep.reana...\n",
       "    dataset_title:  NCEP-NCAR Reanalysis 1"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ds"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>year</th>\n",
       "      <th>month</th>\n",
       "      <th>Unnamed: 0</th>\n",
       "      <th>day</th>\n",
       "      <th>RMM1</th>\n",
       "      <th>RMM2</th>\n",
       "      <th>phase</th>\n",
       "      <th>amplitude</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2015</td>\n",
       "      <td>1</td>\n",
       "      <td>14839.0</td>\n",
       "      <td>16.0</td>\n",
       "      <td>0.240301</td>\n",
       "      <td>1.143472</td>\n",
       "      <td>6.451613</td>\n",
       "      <td>1.576486</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2015</td>\n",
       "      <td>2</td>\n",
       "      <td>14868.5</td>\n",
       "      <td>14.5</td>\n",
       "      <td>-0.402643</td>\n",
       "      <td>0.628380</td>\n",
       "      <td>6.642857</td>\n",
       "      <td>0.894538</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2015</td>\n",
       "      <td>3</td>\n",
       "      <td>14898.0</td>\n",
       "      <td>16.0</td>\n",
       "      <td>-0.615814</td>\n",
       "      <td>0.858320</td>\n",
       "      <td>5.161290</td>\n",
       "      <td>2.404735</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2015</td>\n",
       "      <td>4</td>\n",
       "      <td>14928.5</td>\n",
       "      <td>15.5</td>\n",
       "      <td>0.494468</td>\n",
       "      <td>-0.745644</td>\n",
       "      <td>3.733333</td>\n",
       "      <td>1.042428</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2015</td>\n",
       "      <td>5</td>\n",
       "      <td>14959.0</td>\n",
       "      <td>16.0</td>\n",
       "      <td>-0.067212</td>\n",
       "      <td>0.217109</td>\n",
       "      <td>4.483871</td>\n",
       "      <td>0.671891</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>67</th>\n",
       "      <td>2020</td>\n",
       "      <td>8</td>\n",
       "      <td>16878.0</td>\n",
       "      <td>16.0</td>\n",
       "      <td>-0.443908</td>\n",
       "      <td>-0.230977</td>\n",
       "      <td>4.548387</td>\n",
       "      <td>1.551213</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>68</th>\n",
       "      <td>2020</td>\n",
       "      <td>9</td>\n",
       "      <td>16908.5</td>\n",
       "      <td>15.5</td>\n",
       "      <td>0.800916</td>\n",
       "      <td>-0.101859</td>\n",
       "      <td>4.100000</td>\n",
       "      <td>1.002244</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>69</th>\n",
       "      <td>2020</td>\n",
       "      <td>10</td>\n",
       "      <td>16939.0</td>\n",
       "      <td>16.0</td>\n",
       "      <td>1.314870</td>\n",
       "      <td>0.828408</td>\n",
       "      <td>5.354839</td>\n",
       "      <td>1.773082</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>70</th>\n",
       "      <td>2020</td>\n",
       "      <td>11</td>\n",
       "      <td>16969.5</td>\n",
       "      <td>15.5</td>\n",
       "      <td>-0.327610</td>\n",
       "      <td>-0.293515</td>\n",
       "      <td>4.533333</td>\n",
       "      <td>1.132318</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>71</th>\n",
       "      <td>2020</td>\n",
       "      <td>12</td>\n",
       "      <td>17000.0</td>\n",
       "      <td>16.0</td>\n",
       "      <td>0.651116</td>\n",
       "      <td>0.228639</td>\n",
       "      <td>4.774194</td>\n",
       "      <td>0.826904</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>72 rows × 8 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    year  month  Unnamed: 0   day      RMM1      RMM2     phase  amplitude\n",
       "0   2015      1     14839.0  16.0  0.240301  1.143472  6.451613   1.576486\n",
       "1   2015      2     14868.5  14.5 -0.402643  0.628380  6.642857   0.894538\n",
       "2   2015      3     14898.0  16.0 -0.615814  0.858320  5.161290   2.404735\n",
       "3   2015      4     14928.5  15.5  0.494468 -0.745644  3.733333   1.042428\n",
       "4   2015      5     14959.0  16.0 -0.067212  0.217109  4.483871   0.671891\n",
       "..   ...    ...         ...   ...       ...       ...       ...        ...\n",
       "67  2020      8     16878.0  16.0 -0.443908 -0.230977  4.548387   1.551213\n",
       "68  2020      9     16908.5  15.5  0.800916 -0.101859  4.100000   1.002244\n",
       "69  2020     10     16939.0  16.0  1.314870  0.828408  5.354839   1.773082\n",
       "70  2020     11     16969.5  15.5 -0.327610 -0.293515  4.533333   1.132318\n",
       "71  2020     12     17000.0  16.0  0.651116  0.228639  4.774194   0.826904\n",
       "\n",
       "[72 rows x 8 columns]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#例如对2015-2020年的每年求月平均，可以这样\n",
    "dfg=df.loc[df['year'].isin(np.arange(2015,2021,1))].groupby(['year','month']).mean()\n",
    "dfg=dfg.reset_index()\n",
    "dfg"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><svg style=\"position: absolute; width: 0; height: 0; overflow: hidden\">\n",
       "<defs>\n",
       "<symbol id=\"icon-database\" viewBox=\"0 0 32 32\">\n",
       "<path d=\"M16 0c-8.837 0-16 2.239-16 5v4c0 2.761 7.163 5 16 5s16-2.239 16-5v-4c0-2.761-7.163-5-16-5z\"></path>\n",
       "<path d=\"M16 17c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
       "<path d=\"M16 26c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
       "</symbol>\n",
       "<symbol id=\"icon-file-text2\" viewBox=\"0 0 32 32\">\n",
       "<path d=\"M28.681 7.159c-0.694-0.947-1.662-2.053-2.724-3.116s-2.169-2.030-3.116-2.724c-1.612-1.182-2.393-1.319-2.841-1.319h-15.5c-1.378 0-2.5 1.121-2.5 2.5v27c0 1.378 1.122 2.5 2.5 2.5h23c1.378 0 2.5-1.122 2.5-2.5v-19.5c0-0.448-0.137-1.23-1.319-2.841zM24.543 5.457c0.959 0.959 1.712 1.825 2.268 2.543h-4.811v-4.811c0.718 0.556 1.584 1.309 2.543 2.268zM28 29.5c0 0.271-0.229 0.5-0.5 0.5h-23c-0.271 0-0.5-0.229-0.5-0.5v-27c0-0.271 0.229-0.5 0.5-0.5 0 0 15.499-0 15.5 0v7c0 0.552 0.448 1 1 1h7v19.5z\"></path>\n",
       "<path d=\"M23 26h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
       "<path d=\"M23 22h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
       "<path d=\"M23 18h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
       "</symbol>\n",
       "</defs>\n",
       "</svg>\n",
       "<style>/* CSS stylesheet for displaying xarray objects in jupyterlab.\n",
       " *\n",
       " */\n",
       "\n",
       ":root {\n",
       "  --xr-font-color0: var(--jp-content-font-color0, rgba(0, 0, 0, 1));\n",
       "  --xr-font-color2: var(--jp-content-font-color2, rgba(0, 0, 0, 0.54));\n",
       "  --xr-font-color3: var(--jp-content-font-color3, rgba(0, 0, 0, 0.38));\n",
       "  --xr-border-color: var(--jp-border-color2, #e0e0e0);\n",
       "  --xr-disabled-color: var(--jp-layout-color3, #bdbdbd);\n",
       "  --xr-background-color: var(--jp-layout-color0, white);\n",
       "  --xr-background-color-row-even: var(--jp-layout-color1, white);\n",
       "  --xr-background-color-row-odd: var(--jp-layout-color2, #eeeeee);\n",
       "}\n",
       "\n",
       "html[theme=dark],\n",
       "body.vscode-dark {\n",
       "  --xr-font-color0: rgba(255, 255, 255, 1);\n",
       "  --xr-font-color2: rgba(255, 255, 255, 0.54);\n",
       "  --xr-font-color3: rgba(255, 255, 255, 0.38);\n",
       "  --xr-border-color: #1F1F1F;\n",
       "  --xr-disabled-color: #515151;\n",
       "  --xr-background-color: #111111;\n",
       "  --xr-background-color-row-even: #111111;\n",
       "  --xr-background-color-row-odd: #313131;\n",
       "}\n",
       "\n",
       ".xr-wrap {\n",
       "  display: block !important;\n",
       "  min-width: 300px;\n",
       "  max-width: 700px;\n",
       "}\n",
       "\n",
       ".xr-text-repr-fallback {\n",
       "  /* fallback to plain text repr when CSS is not injected (untrusted notebook) */\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-header {\n",
       "  padding-top: 6px;\n",
       "  padding-bottom: 6px;\n",
       "  margin-bottom: 4px;\n",
       "  border-bottom: solid 1px var(--xr-border-color);\n",
       "}\n",
       "\n",
       ".xr-header > div,\n",
       ".xr-header > ul {\n",
       "  display: inline;\n",
       "  margin-top: 0;\n",
       "  margin-bottom: 0;\n",
       "}\n",
       "\n",
       ".xr-obj-type,\n",
       ".xr-array-name {\n",
       "  margin-left: 2px;\n",
       "  margin-right: 10px;\n",
       "}\n",
       "\n",
       ".xr-obj-type {\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-sections {\n",
       "  padding-left: 0 !important;\n",
       "  display: grid;\n",
       "  grid-template-columns: 150px auto auto 1fr 20px 20px;\n",
       "}\n",
       "\n",
       ".xr-section-item {\n",
       "  display: contents;\n",
       "}\n",
       "\n",
       ".xr-section-item input {\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-section-item input + label {\n",
       "  color: var(--xr-disabled-color);\n",
       "}\n",
       "\n",
       ".xr-section-item input:enabled + label {\n",
       "  cursor: pointer;\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-section-item input:enabled + label:hover {\n",
       "  color: var(--xr-font-color0);\n",
       "}\n",
       "\n",
       ".xr-section-summary {\n",
       "  grid-column: 1;\n",
       "  color: var(--xr-font-color2);\n",
       "  font-weight: 500;\n",
       "}\n",
       "\n",
       ".xr-section-summary > span {\n",
       "  display: inline-block;\n",
       "  padding-left: 0.5em;\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:disabled + label {\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-section-summary-in + label:before {\n",
       "  display: inline-block;\n",
       "  content: '►';\n",
       "  font-size: 11px;\n",
       "  width: 15px;\n",
       "  text-align: center;\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:disabled + label:before {\n",
       "  color: var(--xr-disabled-color);\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:checked + label:before {\n",
       "  content: '▼';\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:checked + label > span {\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-section-summary,\n",
       ".xr-section-inline-details {\n",
       "  padding-top: 4px;\n",
       "  padding-bottom: 4px;\n",
       "}\n",
       "\n",
       ".xr-section-inline-details {\n",
       "  grid-column: 2 / -1;\n",
       "}\n",
       "\n",
       ".xr-section-details {\n",
       "  display: none;\n",
       "  grid-column: 1 / -1;\n",
       "  margin-bottom: 5px;\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:checked ~ .xr-section-details {\n",
       "  display: contents;\n",
       "}\n",
       "\n",
       ".xr-array-wrap {\n",
       "  grid-column: 1 / -1;\n",
       "  display: grid;\n",
       "  grid-template-columns: 20px auto;\n",
       "}\n",
       "\n",
       ".xr-array-wrap > label {\n",
       "  grid-column: 1;\n",
       "  vertical-align: top;\n",
       "}\n",
       "\n",
       ".xr-preview {\n",
       "  color: var(--xr-font-color3);\n",
       "}\n",
       "\n",
       ".xr-array-preview,\n",
       ".xr-array-data {\n",
       "  padding: 0 5px !important;\n",
       "  grid-column: 2;\n",
       "}\n",
       "\n",
       ".xr-array-data,\n",
       ".xr-array-in:checked ~ .xr-array-preview {\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-array-in:checked ~ .xr-array-data,\n",
       ".xr-array-preview {\n",
       "  display: inline-block;\n",
       "}\n",
       "\n",
       ".xr-dim-list {\n",
       "  display: inline-block !important;\n",
       "  list-style: none;\n",
       "  padding: 0 !important;\n",
       "  margin: 0;\n",
       "}\n",
       "\n",
       ".xr-dim-list li {\n",
       "  display: inline-block;\n",
       "  padding: 0;\n",
       "  margin: 0;\n",
       "}\n",
       "\n",
       ".xr-dim-list:before {\n",
       "  content: '(';\n",
       "}\n",
       "\n",
       ".xr-dim-list:after {\n",
       "  content: ')';\n",
       "}\n",
       "\n",
       ".xr-dim-list li:not(:last-child):after {\n",
       "  content: ',';\n",
       "  padding-right: 5px;\n",
       "}\n",
       "\n",
       ".xr-has-index {\n",
       "  font-weight: bold;\n",
       "}\n",
       "\n",
       ".xr-var-list,\n",
       ".xr-var-item {\n",
       "  display: contents;\n",
       "}\n",
       "\n",
       ".xr-var-item > div,\n",
       ".xr-var-item label,\n",
       ".xr-var-item > .xr-var-name span {\n",
       "  background-color: var(--xr-background-color-row-even);\n",
       "  margin-bottom: 0;\n",
       "}\n",
       "\n",
       ".xr-var-item > .xr-var-name:hover span {\n",
       "  padding-right: 5px;\n",
       "}\n",
       "\n",
       ".xr-var-list > li:nth-child(odd) > div,\n",
       ".xr-var-list > li:nth-child(odd) > label,\n",
       ".xr-var-list > li:nth-child(odd) > .xr-var-name span {\n",
       "  background-color: var(--xr-background-color-row-odd);\n",
       "}\n",
       "\n",
       ".xr-var-name {\n",
       "  grid-column: 1;\n",
       "}\n",
       "\n",
       ".xr-var-dims {\n",
       "  grid-column: 2;\n",
       "}\n",
       "\n",
       ".xr-var-dtype {\n",
       "  grid-column: 3;\n",
       "  text-align: right;\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-var-preview {\n",
       "  grid-column: 4;\n",
       "}\n",
       "\n",
       ".xr-var-name,\n",
       ".xr-var-dims,\n",
       ".xr-var-dtype,\n",
       ".xr-preview,\n",
       ".xr-attrs dt {\n",
       "  white-space: nowrap;\n",
       "  overflow: hidden;\n",
       "  text-overflow: ellipsis;\n",
       "  padding-right: 10px;\n",
       "}\n",
       "\n",
       ".xr-var-name:hover,\n",
       ".xr-var-dims:hover,\n",
       ".xr-var-dtype:hover,\n",
       ".xr-attrs dt:hover {\n",
       "  overflow: visible;\n",
       "  width: auto;\n",
       "  z-index: 1;\n",
       "}\n",
       "\n",
       ".xr-var-attrs,\n",
       ".xr-var-data {\n",
       "  display: none;\n",
       "  background-color: var(--xr-background-color) !important;\n",
       "  padding-bottom: 5px !important;\n",
       "}\n",
       "\n",
       ".xr-var-attrs-in:checked ~ .xr-var-attrs,\n",
       ".xr-var-data-in:checked ~ .xr-var-data {\n",
       "  display: block;\n",
       "}\n",
       "\n",
       ".xr-var-data > table {\n",
       "  float: right;\n",
       "}\n",
       "\n",
       ".xr-var-name span,\n",
       ".xr-var-data,\n",
       ".xr-attrs {\n",
       "  padding-left: 25px !important;\n",
       "}\n",
       "\n",
       ".xr-attrs,\n",
       ".xr-var-attrs,\n",
       ".xr-var-data {\n",
       "  grid-column: 1 / -1;\n",
       "}\n",
       "\n",
       "dl.xr-attrs {\n",
       "  padding: 0;\n",
       "  margin: 0;\n",
       "  display: grid;\n",
       "  grid-template-columns: 125px auto;\n",
       "}\n",
       "\n",
       ".xr-attrs dt,\n",
       ".xr-attrs dd {\n",
       "  padding: 0;\n",
       "  margin: 0;\n",
       "  float: left;\n",
       "  padding-right: 10px;\n",
       "  width: auto;\n",
       "}\n",
       "\n",
       ".xr-attrs dt {\n",
       "  font-weight: normal;\n",
       "  grid-column: 1;\n",
       "}\n",
       "\n",
       ".xr-attrs dt:hover span {\n",
       "  display: inline-block;\n",
       "  background: var(--xr-background-color);\n",
       "  padding-right: 10px;\n",
       "}\n",
       "\n",
       ".xr-attrs dd {\n",
       "  grid-column: 2;\n",
       "  white-space: pre-wrap;\n",
       "  word-break: break-all;\n",
       "}\n",
       "\n",
       ".xr-icon-database,\n",
       ".xr-icon-file-text2 {\n",
       "  display: inline-block;\n",
       "  vertical-align: middle;\n",
       "  width: 1em;\n",
       "  height: 1.5em !important;\n",
       "  stroke-width: 0;\n",
       "  stroke: currentColor;\n",
       "  fill: currentColor;\n",
       "}\n",
       "</style><pre class='xr-text-repr-fallback'>&lt;xarray.DataArray &#x27;hgt&#x27; (year: 40, level: 17, lat: 73, lon: 144)&gt;\n",
       "array([[[[  101.15549 ,   101.15549 ,   101.15549 , ...,   101.15549 ,\n",
       "            101.15549 ,   101.15549 ],\n",
       "         [   94.58851 ,    94.51777 ,    94.46804 , ...,    94.95754 ,\n",
       "             94.82125 ,    94.68524 ],\n",
       "         [   91.37087 ,    90.8632  ,    90.42919 , ...,    93.394554,\n",
       "             92.62619 ,    91.939735],\n",
       "         ...,\n",
       "         [  152.7201  ,   158.85332 ,   164.69194 , ...,   133.00615 ,\n",
       "            139.77956 ,   146.35454 ],\n",
       "         [  166.8888  ,   169.92932 ,   172.8835  , ...,   157.50557 ,\n",
       "            160.66985 ,   163.78166 ],\n",
       "         [  158.39255 ,   158.39255 ,   158.39255 , ...,   158.39255 ,\n",
       "            158.39255 ,   158.39255 ]],\n",
       "\n",
       "        [[  693.31683 ,   693.31683 ,   693.31683 , ...,   693.31683 ,\n",
       "            693.31683 ,   693.31683 ],\n",
       "         [  686.43896 ,   686.4351  ,   686.467   , ...,   686.43427 ,\n",
       "            686.43384 ,   686.3916  ],\n",
       "         [  682.49786 ,   682.26355 ,   682.11597 , ...,   683.6149  ,\n",
       "            683.1882  ,   682.78375 ],\n",
       "...\n",
       "         [24831.195   , 24829.828   , 24828.44    , ..., 24835.428   ,\n",
       "          24833.986   , 24832.617   ],\n",
       "         [24826.39    , 24825.748   , 24825.111   , ..., 24828.5     ,\n",
       "          24827.771   , 24827.086   ],\n",
       "         [24834.43    , 24834.43    , 24834.43    , ..., 24834.43    ,\n",
       "          24834.43    , 24834.43    ]],\n",
       "\n",
       "        [[30617.615   , 30617.615   , 30617.615   , ..., 30617.615   ,\n",
       "          30617.615   , 30617.615   ],\n",
       "         [30581.475   , 30580.365   , 30579.422   , ..., 30584.951   ,\n",
       "          30583.752   , 30582.557   ],\n",
       "         [30549.072   , 30546.88    , 30544.803   , ..., 30556.213   ,\n",
       "          30553.752   , 30551.377   ],\n",
       "         ...,\n",
       "         [29187.924   , 29186.947   , 29186.088   , ..., 29192.057   ,\n",
       "          29190.506   , 29189.143   ],\n",
       "         [29189.156   , 29188.596   , 29188.053   , ..., 29191.25    ,\n",
       "          29190.502   , 29189.81    ],\n",
       "         [29205.365   , 29205.365   , 29205.365   , ..., 29205.365   ,\n",
       "          29205.365   , 29205.365   ]]]], dtype=float32)\n",
       "Coordinates:\n",
       "  * level    (level) float32 1e+03 925.0 850.0 700.0 ... 50.0 30.0 20.0 10.0\n",
       "  * lat      (lat) float32 90.0 87.5 85.0 82.5 80.0 ... -82.5 -85.0 -87.5 -90.0\n",
       "  * lon      (lon) float32 0.0 2.5 5.0 7.5 10.0 ... 350.0 352.5 355.0 357.5\n",
       "  * year     (year) int64 1971 1972 1973 1974 1975 ... 2006 2007 2008 2009 2010</pre><div class='xr-wrap' style='display:none'><div class='xr-header'><div class='xr-obj-type'>xarray.DataArray</div><div class='xr-array-name'>'hgt'</div><ul class='xr-dim-list'><li><span class='xr-has-index'>year</span>: 40</li><li><span class='xr-has-index'>level</span>: 17</li><li><span class='xr-has-index'>lat</span>: 73</li><li><span class='xr-has-index'>lon</span>: 144</li></ul></div><ul class='xr-sections'><li class='xr-section-item'><div class='xr-array-wrap'><input id='section-f6ee0a91-a2a9-488c-bf1b-9269ad14c8f6' class='xr-array-in' type='checkbox' checked><label for='section-f6ee0a91-a2a9-488c-bf1b-9269ad14c8f6' title='Show/hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-array-preview xr-preview'><span>101.2 101.2 101.2 101.2 ... 2.921e+04 2.921e+04 2.921e+04 2.921e+04</span></div><div class='xr-array-data'><pre>array([[[[  101.15549 ,   101.15549 ,   101.15549 , ...,   101.15549 ,\n",
       "            101.15549 ,   101.15549 ],\n",
       "         [   94.58851 ,    94.51777 ,    94.46804 , ...,    94.95754 ,\n",
       "             94.82125 ,    94.68524 ],\n",
       "         [   91.37087 ,    90.8632  ,    90.42919 , ...,    93.394554,\n",
       "             92.62619 ,    91.939735],\n",
       "         ...,\n",
       "         [  152.7201  ,   158.85332 ,   164.69194 , ...,   133.00615 ,\n",
       "            139.77956 ,   146.35454 ],\n",
       "         [  166.8888  ,   169.92932 ,   172.8835  , ...,   157.50557 ,\n",
       "            160.66985 ,   163.78166 ],\n",
       "         [  158.39255 ,   158.39255 ,   158.39255 , ...,   158.39255 ,\n",
       "            158.39255 ,   158.39255 ]],\n",
       "\n",
       "        [[  693.31683 ,   693.31683 ,   693.31683 , ...,   693.31683 ,\n",
       "            693.31683 ,   693.31683 ],\n",
       "         [  686.43896 ,   686.4351  ,   686.467   , ...,   686.43427 ,\n",
       "            686.43384 ,   686.3916  ],\n",
       "         [  682.49786 ,   682.26355 ,   682.11597 , ...,   683.6149  ,\n",
       "            683.1882  ,   682.78375 ],\n",
       "...\n",
       "         [24831.195   , 24829.828   , 24828.44    , ..., 24835.428   ,\n",
       "          24833.986   , 24832.617   ],\n",
       "         [24826.39    , 24825.748   , 24825.111   , ..., 24828.5     ,\n",
       "          24827.771   , 24827.086   ],\n",
       "         [24834.43    , 24834.43    , 24834.43    , ..., 24834.43    ,\n",
       "          24834.43    , 24834.43    ]],\n",
       "\n",
       "        [[30617.615   , 30617.615   , 30617.615   , ..., 30617.615   ,\n",
       "          30617.615   , 30617.615   ],\n",
       "         [30581.475   , 30580.365   , 30579.422   , ..., 30584.951   ,\n",
       "          30583.752   , 30582.557   ],\n",
       "         [30549.072   , 30546.88    , 30544.803   , ..., 30556.213   ,\n",
       "          30553.752   , 30551.377   ],\n",
       "         ...,\n",
       "         [29187.924   , 29186.947   , 29186.088   , ..., 29192.057   ,\n",
       "          29190.506   , 29189.143   ],\n",
       "         [29189.156   , 29188.596   , 29188.053   , ..., 29191.25    ,\n",
       "          29190.502   , 29189.81    ],\n",
       "         [29205.365   , 29205.365   , 29205.365   , ..., 29205.365   ,\n",
       "          29205.365   , 29205.365   ]]]], dtype=float32)</pre></div></div></li><li class='xr-section-item'><input id='section-dc2d6b2b-9a17-4740-aac7-2be8cd59882a' class='xr-section-summary-in' type='checkbox'  checked><label for='section-dc2d6b2b-9a17-4740-aac7-2be8cd59882a' class='xr-section-summary' >Coordinates: <span>(4)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>level</span></div><div class='xr-var-dims'>(level)</div><div class='xr-var-dtype'>float32</div><div class='xr-var-preview xr-preview'>1e+03 925.0 850.0 ... 20.0 10.0</div><input id='attrs-b18a10ee-f293-4645-8b0c-dc2ae31318c3' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-b18a10ee-f293-4645-8b0c-dc2ae31318c3' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-f0fd22b4-fcdf-4a63-82b4-b77e56c01fae' class='xr-var-data-in' type='checkbox'><label for='data-f0fd22b4-fcdf-4a63-82b4-b77e56c01fae' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>units :</span></dt><dd>millibar</dd><dt><span>long_name :</span></dt><dd>Level</dd><dt><span>positive :</span></dt><dd>down</dd><dt><span>GRIB_id :</span></dt><dd>100</dd><dt><span>GRIB_name :</span></dt><dd>hPa</dd><dt><span>actual_range :</span></dt><dd>[1000.   10.]</dd><dt><span>axis :</span></dt><dd>Z</dd></dl></div><div class='xr-var-data'><pre>array([1000.,  925.,  850.,  700.,  600.,  500.,  400.,  300.,  250.,  200.,\n",
       "        150.,  100.,   70.,   50.,   30.,   20.,   10.], dtype=float32)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>lat</span></div><div class='xr-var-dims'>(lat)</div><div class='xr-var-dtype'>float32</div><div class='xr-var-preview xr-preview'>90.0 87.5 85.0 ... -87.5 -90.0</div><input id='attrs-c99d589d-ef95-4ff1-aba9-060b9d4bc348' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-c99d589d-ef95-4ff1-aba9-060b9d4bc348' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-c5cd6849-2f02-43e0-b415-e5b783640acd' class='xr-var-data-in' type='checkbox'><label for='data-c5cd6849-2f02-43e0-b415-e5b783640acd' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>units :</span></dt><dd>degrees_north</dd><dt><span>actual_range :</span></dt><dd>[ 90. -90.]</dd><dt><span>long_name :</span></dt><dd>Latitude</dd><dt><span>standard_name :</span></dt><dd>latitude</dd><dt><span>axis :</span></dt><dd>Y</dd></dl></div><div class='xr-var-data'><pre>array([ 90. ,  87.5,  85. ,  82.5,  80. ,  77.5,  75. ,  72.5,  70. ,  67.5,\n",
       "        65. ,  62.5,  60. ,  57.5,  55. ,  52.5,  50. ,  47.5,  45. ,  42.5,\n",
       "        40. ,  37.5,  35. ,  32.5,  30. ,  27.5,  25. ,  22.5,  20. ,  17.5,\n",
       "        15. ,  12.5,  10. ,   7.5,   5. ,   2.5,   0. ,  -2.5,  -5. ,  -7.5,\n",
       "       -10. , -12.5, -15. , -17.5, -20. , -22.5, -25. , -27.5, -30. , -32.5,\n",
       "       -35. , -37.5, -40. , -42.5, -45. , -47.5, -50. , -52.5, -55. , -57.5,\n",
       "       -60. , -62.5, -65. , -67.5, -70. , -72.5, -75. , -77.5, -80. , -82.5,\n",
       "       -85. , -87.5, -90. ], dtype=float32)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>lon</span></div><div class='xr-var-dims'>(lon)</div><div class='xr-var-dtype'>float32</div><div class='xr-var-preview xr-preview'>0.0 2.5 5.0 ... 352.5 355.0 357.5</div><input id='attrs-e3566077-cd2f-4e93-be32-e76162741517' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-e3566077-cd2f-4e93-be32-e76162741517' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-58e86965-f5d9-46f2-b430-1e06d8b29eca' class='xr-var-data-in' type='checkbox'><label for='data-58e86965-f5d9-46f2-b430-1e06d8b29eca' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>units :</span></dt><dd>degrees_east</dd><dt><span>long_name :</span></dt><dd>Longitude</dd><dt><span>actual_range :</span></dt><dd>[  0.  357.5]</dd><dt><span>standard_name :</span></dt><dd>longitude</dd><dt><span>axis :</span></dt><dd>X</dd></dl></div><div class='xr-var-data'><pre>array([  0. ,   2.5,   5. ,   7.5,  10. ,  12.5,  15. ,  17.5,  20. ,  22.5,\n",
       "        25. ,  27.5,  30. ,  32.5,  35. ,  37.5,  40. ,  42.5,  45. ,  47.5,\n",
       "        50. ,  52.5,  55. ,  57.5,  60. ,  62.5,  65. ,  67.5,  70. ,  72.5,\n",
       "        75. ,  77.5,  80. ,  82.5,  85. ,  87.5,  90. ,  92.5,  95. ,  97.5,\n",
       "       100. , 102.5, 105. , 107.5, 110. , 112.5, 115. , 117.5, 120. , 122.5,\n",
       "       125. , 127.5, 130. , 132.5, 135. , 137.5, 140. , 142.5, 145. , 147.5,\n",
       "       150. , 152.5, 155. , 157.5, 160. , 162.5, 165. , 167.5, 170. , 172.5,\n",
       "       175. , 177.5, 180. , 182.5, 185. , 187.5, 190. , 192.5, 195. , 197.5,\n",
       "       200. , 202.5, 205. , 207.5, 210. , 212.5, 215. , 217.5, 220. , 222.5,\n",
       "       225. , 227.5, 230. , 232.5, 235. , 237.5, 240. , 242.5, 245. , 247.5,\n",
       "       250. , 252.5, 255. , 257.5, 260. , 262.5, 265. , 267.5, 270. , 272.5,\n",
       "       275. , 277.5, 280. , 282.5, 285. , 287.5, 290. , 292.5, 295. , 297.5,\n",
       "       300. , 302.5, 305. , 307.5, 310. , 312.5, 315. , 317.5, 320. , 322.5,\n",
       "       325. , 327.5, 330. , 332.5, 335. , 337.5, 340. , 342.5, 345. , 347.5,\n",
       "       350. , 352.5, 355. , 357.5], dtype=float32)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>year</span></div><div class='xr-var-dims'>(year)</div><div class='xr-var-dtype'>int64</div><div class='xr-var-preview xr-preview'>1971 1972 1973 ... 2008 2009 2010</div><input id='attrs-bfbd1c2e-0048-435e-bdfc-0d67b5d9703f' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-bfbd1c2e-0048-435e-bdfc-0d67b5d9703f' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-62acd699-b4e7-45e2-8e5d-e3e06fa4d26b' class='xr-var-data-in' type='checkbox'><label for='data-62acd699-b4e7-45e2-8e5d-e3e06fa4d26b' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982,\n",
       "       1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,\n",
       "       1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,\n",
       "       2007, 2008, 2009, 2010], dtype=int64)</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-cc358a24-9ed0-4379-a58d-27f0a9eaa2e5' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-cc358a24-9ed0-4379-a58d-27f0a9eaa2e5' class='xr-section-summary'  title='Expand/collapse section'>Attributes: <span>(0)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><dl class='xr-attrs'></dl></div></li></ul></div></div>"
      ],
      "text/plain": [
       "<xarray.DataArray 'hgt' (year: 40, level: 17, lat: 73, lon: 144)>\n",
       "array([[[[  101.15549 ,   101.15549 ,   101.15549 , ...,   101.15549 ,\n",
       "            101.15549 ,   101.15549 ],\n",
       "         [   94.58851 ,    94.51777 ,    94.46804 , ...,    94.95754 ,\n",
       "             94.82125 ,    94.68524 ],\n",
       "         [   91.37087 ,    90.8632  ,    90.42919 , ...,    93.394554,\n",
       "             92.62619 ,    91.939735],\n",
       "         ...,\n",
       "         [  152.7201  ,   158.85332 ,   164.69194 , ...,   133.00615 ,\n",
       "            139.77956 ,   146.35454 ],\n",
       "         [  166.8888  ,   169.92932 ,   172.8835  , ...,   157.50557 ,\n",
       "            160.66985 ,   163.78166 ],\n",
       "         [  158.39255 ,   158.39255 ,   158.39255 , ...,   158.39255 ,\n",
       "            158.39255 ,   158.39255 ]],\n",
       "\n",
       "        [[  693.31683 ,   693.31683 ,   693.31683 , ...,   693.31683 ,\n",
       "            693.31683 ,   693.31683 ],\n",
       "         [  686.43896 ,   686.4351  ,   686.467   , ...,   686.43427 ,\n",
       "            686.43384 ,   686.3916  ],\n",
       "         [  682.49786 ,   682.26355 ,   682.11597 , ...,   683.6149  ,\n",
       "            683.1882  ,   682.78375 ],\n",
       "...\n",
       "         [24831.195   , 24829.828   , 24828.44    , ..., 24835.428   ,\n",
       "          24833.986   , 24832.617   ],\n",
       "         [24826.39    , 24825.748   , 24825.111   , ..., 24828.5     ,\n",
       "          24827.771   , 24827.086   ],\n",
       "         [24834.43    , 24834.43    , 24834.43    , ..., 24834.43    ,\n",
       "          24834.43    , 24834.43    ]],\n",
       "\n",
       "        [[30617.615   , 30617.615   , 30617.615   , ..., 30617.615   ,\n",
       "          30617.615   , 30617.615   ],\n",
       "         [30581.475   , 30580.365   , 30579.422   , ..., 30584.951   ,\n",
       "          30583.752   , 30582.557   ],\n",
       "         [30549.072   , 30546.88    , 30544.803   , ..., 30556.213   ,\n",
       "          30553.752   , 30551.377   ],\n",
       "         ...,\n",
       "         [29187.924   , 29186.947   , 29186.088   , ..., 29192.057   ,\n",
       "          29190.506   , 29189.143   ],\n",
       "         [29189.156   , 29188.596   , 29188.053   , ..., 29191.25    ,\n",
       "          29190.502   , 29189.81    ],\n",
       "         [29205.365   , 29205.365   , 29205.365   , ..., 29205.365   ,\n",
       "          29205.365   , 29205.365   ]]]], dtype=float32)\n",
       "Coordinates:\n",
       "  * level    (level) float32 1e+03 925.0 850.0 700.0 ... 50.0 30.0 20.0 10.0\n",
       "  * lat      (lat) float32 90.0 87.5 85.0 82.5 80.0 ... -82.5 -85.0 -87.5 -90.0\n",
       "  * lon      (lon) float32 0.0 2.5 5.0 7.5 10.0 ... 350.0 352.5 355.0 357.5\n",
       "  * year     (year) int64 1971 1972 1973 1974 1975 ... 2006 2007 2008 2009 2010"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 对于dataset来说（xarray）1970-2010\n",
    "\n",
    "hgt=ds['hgt'].groupby(ds.time.dt.year).mean(dim='time').loc['19700101':'20100101',:,:,:]\n",
    "hgt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><svg style=\"position: absolute; width: 0; height: 0; overflow: hidden\">\n",
       "<defs>\n",
       "<symbol id=\"icon-database\" viewBox=\"0 0 32 32\">\n",
       "<path d=\"M16 0c-8.837 0-16 2.239-16 5v4c0 2.761 7.163 5 16 5s16-2.239 16-5v-4c0-2.761-7.163-5-16-5z\"></path>\n",
       "<path d=\"M16 17c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
       "<path d=\"M16 26c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z\"></path>\n",
       "</symbol>\n",
       "<symbol id=\"icon-file-text2\" viewBox=\"0 0 32 32\">\n",
       "<path d=\"M28.681 7.159c-0.694-0.947-1.662-2.053-2.724-3.116s-2.169-2.030-3.116-2.724c-1.612-1.182-2.393-1.319-2.841-1.319h-15.5c-1.378 0-2.5 1.121-2.5 2.5v27c0 1.378 1.122 2.5 2.5 2.5h23c1.378 0 2.5-1.122 2.5-2.5v-19.5c0-0.448-0.137-1.23-1.319-2.841zM24.543 5.457c0.959 0.959 1.712 1.825 2.268 2.543h-4.811v-4.811c0.718 0.556 1.584 1.309 2.543 2.268zM28 29.5c0 0.271-0.229 0.5-0.5 0.5h-23c-0.271 0-0.5-0.229-0.5-0.5v-27c0-0.271 0.229-0.5 0.5-0.5 0 0 15.499-0 15.5 0v7c0 0.552 0.448 1 1 1h7v19.5z\"></path>\n",
       "<path d=\"M23 26h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
       "<path d=\"M23 22h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
       "<path d=\"M23 18h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z\"></path>\n",
       "</symbol>\n",
       "</defs>\n",
       "</svg>\n",
       "<style>/* CSS stylesheet for displaying xarray objects in jupyterlab.\n",
       " *\n",
       " */\n",
       "\n",
       ":root {\n",
       "  --xr-font-color0: var(--jp-content-font-color0, rgba(0, 0, 0, 1));\n",
       "  --xr-font-color2: var(--jp-content-font-color2, rgba(0, 0, 0, 0.54));\n",
       "  --xr-font-color3: var(--jp-content-font-color3, rgba(0, 0, 0, 0.38));\n",
       "  --xr-border-color: var(--jp-border-color2, #e0e0e0);\n",
       "  --xr-disabled-color: var(--jp-layout-color3, #bdbdbd);\n",
       "  --xr-background-color: var(--jp-layout-color0, white);\n",
       "  --xr-background-color-row-even: var(--jp-layout-color1, white);\n",
       "  --xr-background-color-row-odd: var(--jp-layout-color2, #eeeeee);\n",
       "}\n",
       "\n",
       "html[theme=dark],\n",
       "body.vscode-dark {\n",
       "  --xr-font-color0: rgba(255, 255, 255, 1);\n",
       "  --xr-font-color2: rgba(255, 255, 255, 0.54);\n",
       "  --xr-font-color3: rgba(255, 255, 255, 0.38);\n",
       "  --xr-border-color: #1F1F1F;\n",
       "  --xr-disabled-color: #515151;\n",
       "  --xr-background-color: #111111;\n",
       "  --xr-background-color-row-even: #111111;\n",
       "  --xr-background-color-row-odd: #313131;\n",
       "}\n",
       "\n",
       ".xr-wrap {\n",
       "  display: block !important;\n",
       "  min-width: 300px;\n",
       "  max-width: 700px;\n",
       "}\n",
       "\n",
       ".xr-text-repr-fallback {\n",
       "  /* fallback to plain text repr when CSS is not injected (untrusted notebook) */\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-header {\n",
       "  padding-top: 6px;\n",
       "  padding-bottom: 6px;\n",
       "  margin-bottom: 4px;\n",
       "  border-bottom: solid 1px var(--xr-border-color);\n",
       "}\n",
       "\n",
       ".xr-header > div,\n",
       ".xr-header > ul {\n",
       "  display: inline;\n",
       "  margin-top: 0;\n",
       "  margin-bottom: 0;\n",
       "}\n",
       "\n",
       ".xr-obj-type,\n",
       ".xr-array-name {\n",
       "  margin-left: 2px;\n",
       "  margin-right: 10px;\n",
       "}\n",
       "\n",
       ".xr-obj-type {\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-sections {\n",
       "  padding-left: 0 !important;\n",
       "  display: grid;\n",
       "  grid-template-columns: 150px auto auto 1fr 20px 20px;\n",
       "}\n",
       "\n",
       ".xr-section-item {\n",
       "  display: contents;\n",
       "}\n",
       "\n",
       ".xr-section-item input {\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-section-item input + label {\n",
       "  color: var(--xr-disabled-color);\n",
       "}\n",
       "\n",
       ".xr-section-item input:enabled + label {\n",
       "  cursor: pointer;\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-section-item input:enabled + label:hover {\n",
       "  color: var(--xr-font-color0);\n",
       "}\n",
       "\n",
       ".xr-section-summary {\n",
       "  grid-column: 1;\n",
       "  color: var(--xr-font-color2);\n",
       "  font-weight: 500;\n",
       "}\n",
       "\n",
       ".xr-section-summary > span {\n",
       "  display: inline-block;\n",
       "  padding-left: 0.5em;\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:disabled + label {\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-section-summary-in + label:before {\n",
       "  display: inline-block;\n",
       "  content: '►';\n",
       "  font-size: 11px;\n",
       "  width: 15px;\n",
       "  text-align: center;\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:disabled + label:before {\n",
       "  color: var(--xr-disabled-color);\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:checked + label:before {\n",
       "  content: '▼';\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:checked + label > span {\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-section-summary,\n",
       ".xr-section-inline-details {\n",
       "  padding-top: 4px;\n",
       "  padding-bottom: 4px;\n",
       "}\n",
       "\n",
       ".xr-section-inline-details {\n",
       "  grid-column: 2 / -1;\n",
       "}\n",
       "\n",
       ".xr-section-details {\n",
       "  display: none;\n",
       "  grid-column: 1 / -1;\n",
       "  margin-bottom: 5px;\n",
       "}\n",
       "\n",
       ".xr-section-summary-in:checked ~ .xr-section-details {\n",
       "  display: contents;\n",
       "}\n",
       "\n",
       ".xr-array-wrap {\n",
       "  grid-column: 1 / -1;\n",
       "  display: grid;\n",
       "  grid-template-columns: 20px auto;\n",
       "}\n",
       "\n",
       ".xr-array-wrap > label {\n",
       "  grid-column: 1;\n",
       "  vertical-align: top;\n",
       "}\n",
       "\n",
       ".xr-preview {\n",
       "  color: var(--xr-font-color3);\n",
       "}\n",
       "\n",
       ".xr-array-preview,\n",
       ".xr-array-data {\n",
       "  padding: 0 5px !important;\n",
       "  grid-column: 2;\n",
       "}\n",
       "\n",
       ".xr-array-data,\n",
       ".xr-array-in:checked ~ .xr-array-preview {\n",
       "  display: none;\n",
       "}\n",
       "\n",
       ".xr-array-in:checked ~ .xr-array-data,\n",
       ".xr-array-preview {\n",
       "  display: inline-block;\n",
       "}\n",
       "\n",
       ".xr-dim-list {\n",
       "  display: inline-block !important;\n",
       "  list-style: none;\n",
       "  padding: 0 !important;\n",
       "  margin: 0;\n",
       "}\n",
       "\n",
       ".xr-dim-list li {\n",
       "  display: inline-block;\n",
       "  padding: 0;\n",
       "  margin: 0;\n",
       "}\n",
       "\n",
       ".xr-dim-list:before {\n",
       "  content: '(';\n",
       "}\n",
       "\n",
       ".xr-dim-list:after {\n",
       "  content: ')';\n",
       "}\n",
       "\n",
       ".xr-dim-list li:not(:last-child):after {\n",
       "  content: ',';\n",
       "  padding-right: 5px;\n",
       "}\n",
       "\n",
       ".xr-has-index {\n",
       "  font-weight: bold;\n",
       "}\n",
       "\n",
       ".xr-var-list,\n",
       ".xr-var-item {\n",
       "  display: contents;\n",
       "}\n",
       "\n",
       ".xr-var-item > div,\n",
       ".xr-var-item label,\n",
       ".xr-var-item > .xr-var-name span {\n",
       "  background-color: var(--xr-background-color-row-even);\n",
       "  margin-bottom: 0;\n",
       "}\n",
       "\n",
       ".xr-var-item > .xr-var-name:hover span {\n",
       "  padding-right: 5px;\n",
       "}\n",
       "\n",
       ".xr-var-list > li:nth-child(odd) > div,\n",
       ".xr-var-list > li:nth-child(odd) > label,\n",
       ".xr-var-list > li:nth-child(odd) > .xr-var-name span {\n",
       "  background-color: var(--xr-background-color-row-odd);\n",
       "}\n",
       "\n",
       ".xr-var-name {\n",
       "  grid-column: 1;\n",
       "}\n",
       "\n",
       ".xr-var-dims {\n",
       "  grid-column: 2;\n",
       "}\n",
       "\n",
       ".xr-var-dtype {\n",
       "  grid-column: 3;\n",
       "  text-align: right;\n",
       "  color: var(--xr-font-color2);\n",
       "}\n",
       "\n",
       ".xr-var-preview {\n",
       "  grid-column: 4;\n",
       "}\n",
       "\n",
       ".xr-var-name,\n",
       ".xr-var-dims,\n",
       ".xr-var-dtype,\n",
       ".xr-preview,\n",
       ".xr-attrs dt {\n",
       "  white-space: nowrap;\n",
       "  overflow: hidden;\n",
       "  text-overflow: ellipsis;\n",
       "  padding-right: 10px;\n",
       "}\n",
       "\n",
       ".xr-var-name:hover,\n",
       ".xr-var-dims:hover,\n",
       ".xr-var-dtype:hover,\n",
       ".xr-attrs dt:hover {\n",
       "  overflow: visible;\n",
       "  width: auto;\n",
       "  z-index: 1;\n",
       "}\n",
       "\n",
       ".xr-var-attrs,\n",
       ".xr-var-data {\n",
       "  display: none;\n",
       "  background-color: var(--xr-background-color) !important;\n",
       "  padding-bottom: 5px !important;\n",
       "}\n",
       "\n",
       ".xr-var-attrs-in:checked ~ .xr-var-attrs,\n",
       ".xr-var-data-in:checked ~ .xr-var-data {\n",
       "  display: block;\n",
       "}\n",
       "\n",
       ".xr-var-data > table {\n",
       "  float: right;\n",
       "}\n",
       "\n",
       ".xr-var-name span,\n",
       ".xr-var-data,\n",
       ".xr-attrs {\n",
       "  padding-left: 25px !important;\n",
       "}\n",
       "\n",
       ".xr-attrs,\n",
       ".xr-var-attrs,\n",
       ".xr-var-data {\n",
       "  grid-column: 1 / -1;\n",
       "}\n",
       "\n",
       "dl.xr-attrs {\n",
       "  padding: 0;\n",
       "  margin: 0;\n",
       "  display: grid;\n",
       "  grid-template-columns: 125px auto;\n",
       "}\n",
       "\n",
       ".xr-attrs dt,\n",
       ".xr-attrs dd {\n",
       "  padding: 0;\n",
       "  margin: 0;\n",
       "  float: left;\n",
       "  padding-right: 10px;\n",
       "  width: auto;\n",
       "}\n",
       "\n",
       ".xr-attrs dt {\n",
       "  font-weight: normal;\n",
       "  grid-column: 1;\n",
       "}\n",
       "\n",
       ".xr-attrs dt:hover span {\n",
       "  display: inline-block;\n",
       "  background: var(--xr-background-color);\n",
       "  padding-right: 10px;\n",
       "}\n",
       "\n",
       ".xr-attrs dd {\n",
       "  grid-column: 2;\n",
       "  white-space: pre-wrap;\n",
       "  word-break: break-all;\n",
       "}\n",
       "\n",
       ".xr-icon-database,\n",
       ".xr-icon-file-text2 {\n",
       "  display: inline-block;\n",
       "  vertical-align: middle;\n",
       "  width: 1em;\n",
       "  height: 1.5em !important;\n",
       "  stroke-width: 0;\n",
       "  stroke: currentColor;\n",
       "  fill: currentColor;\n",
       "}\n",
       "</style><pre class='xr-text-repr-fallback'>&lt;xarray.DataArray &#x27;hgt&#x27; (level: 17, lat: 73, lon: 144)&gt;\n",
       "array([[[  125.18029 ,   125.18029 ,   125.18029 , ...,   125.18029 ,\n",
       "           125.18029 ,   125.18029 ],\n",
       "        [  124.14675 ,   123.99787 ,   123.81977 , ...,   124.7157  ,\n",
       "           124.50152 ,   124.34173 ],\n",
       "        [  123.541084,   123.09136 ,   122.68626 , ...,   125.17368 ,\n",
       "           124.57856 ,   124.0277  ],\n",
       "        ...,\n",
       "        [  164.80504 ,   171.08635 ,   176.92877 , ...,   143.55917 ,\n",
       "           151.0109  ,   158.10338 ],\n",
       "        [  159.59138 ,   162.39555 ,   165.04416 , ...,   150.40852 ,\n",
       "           153.57771 ,   156.6823  ],\n",
       "        [  122.65192 ,   122.65192 ,   122.65192 , ...,   122.65192 ,\n",
       "           122.65192 ,   122.65192 ]],\n",
       "\n",
       "       [[  723.87524 ,   723.87524 ,   723.87524 , ...,   723.87524 ,\n",
       "           723.87524 ,   723.87524 ],\n",
       "        [  721.89105 ,   721.7818  ,   721.6912  , ...,   722.2271  ,\n",
       "           722.1367  ,   722.019   ],\n",
       "        [  721.1213  ,   720.8413  ,   720.64215 , ...,   722.0701  ,\n",
       "           721.71173 ,   721.3724  ],\n",
       "...\n",
       "        [24831.195   , 24829.828   , 24828.44    , ..., 24835.428   ,\n",
       "         24833.986   , 24832.617   ],\n",
       "        [24826.39    , 24825.748   , 24825.111   , ..., 24828.5     ,\n",
       "         24827.771   , 24827.086   ],\n",
       "        [24834.43    , 24834.43    , 24834.43    , ..., 24834.43    ,\n",
       "         24834.43    , 24834.43    ]],\n",
       "\n",
       "       [[30617.615   , 30617.615   , 30617.615   , ..., 30617.615   ,\n",
       "         30617.615   , 30617.615   ],\n",
       "        [30581.475   , 30580.365   , 30579.422   , ..., 30584.951   ,\n",
       "         30583.752   , 30582.557   ],\n",
       "        [30549.072   , 30546.88    , 30544.803   , ..., 30556.213   ,\n",
       "         30553.752   , 30551.377   ],\n",
       "        ...,\n",
       "        [29187.924   , 29186.947   , 29186.088   , ..., 29192.057   ,\n",
       "         29190.506   , 29189.143   ],\n",
       "        [29189.156   , 29188.596   , 29188.053   , ..., 29191.25    ,\n",
       "         29190.502   , 29189.81    ],\n",
       "        [29205.365   , 29205.365   , 29205.365   , ..., 29205.365   ,\n",
       "         29205.365   , 29205.365   ]]], dtype=float32)\n",
       "Coordinates:\n",
       "  * level    (level) float32 1e+03 925.0 850.0 700.0 ... 50.0 30.0 20.0 10.0\n",
       "  * lat      (lat) float32 90.0 87.5 85.0 82.5 80.0 ... -82.5 -85.0 -87.5 -90.0\n",
       "  * lon      (lon) float32 0.0 2.5 5.0 7.5 10.0 ... 350.0 352.5 355.0 357.5</pre><div class='xr-wrap' style='display:none'><div class='xr-header'><div class='xr-obj-type'>xarray.DataArray</div><div class='xr-array-name'>'hgt'</div><ul class='xr-dim-list'><li><span class='xr-has-index'>level</span>: 17</li><li><span class='xr-has-index'>lat</span>: 73</li><li><span class='xr-has-index'>lon</span>: 144</li></ul></div><ul class='xr-sections'><li class='xr-section-item'><div class='xr-array-wrap'><input id='section-0909bc4a-9eca-462e-bbd2-0da342f1ba0d' class='xr-array-in' type='checkbox' checked><label for='section-0909bc4a-9eca-462e-bbd2-0da342f1ba0d' title='Show/hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-array-preview xr-preview'><span>125.2 125.2 125.2 125.2 ... 2.921e+04 2.921e+04 2.921e+04 2.921e+04</span></div><div class='xr-array-data'><pre>array([[[  125.18029 ,   125.18029 ,   125.18029 , ...,   125.18029 ,\n",
       "           125.18029 ,   125.18029 ],\n",
       "        [  124.14675 ,   123.99787 ,   123.81977 , ...,   124.7157  ,\n",
       "           124.50152 ,   124.34173 ],\n",
       "        [  123.541084,   123.09136 ,   122.68626 , ...,   125.17368 ,\n",
       "           124.57856 ,   124.0277  ],\n",
       "        ...,\n",
       "        [  164.80504 ,   171.08635 ,   176.92877 , ...,   143.55917 ,\n",
       "           151.0109  ,   158.10338 ],\n",
       "        [  159.59138 ,   162.39555 ,   165.04416 , ...,   150.40852 ,\n",
       "           153.57771 ,   156.6823  ],\n",
       "        [  122.65192 ,   122.65192 ,   122.65192 , ...,   122.65192 ,\n",
       "           122.65192 ,   122.65192 ]],\n",
       "\n",
       "       [[  723.87524 ,   723.87524 ,   723.87524 , ...,   723.87524 ,\n",
       "           723.87524 ,   723.87524 ],\n",
       "        [  721.89105 ,   721.7818  ,   721.6912  , ...,   722.2271  ,\n",
       "           722.1367  ,   722.019   ],\n",
       "        [  721.1213  ,   720.8413  ,   720.64215 , ...,   722.0701  ,\n",
       "           721.71173 ,   721.3724  ],\n",
       "...\n",
       "        [24831.195   , 24829.828   , 24828.44    , ..., 24835.428   ,\n",
       "         24833.986   , 24832.617   ],\n",
       "        [24826.39    , 24825.748   , 24825.111   , ..., 24828.5     ,\n",
       "         24827.771   , 24827.086   ],\n",
       "        [24834.43    , 24834.43    , 24834.43    , ..., 24834.43    ,\n",
       "         24834.43    , 24834.43    ]],\n",
       "\n",
       "       [[30617.615   , 30617.615   , 30617.615   , ..., 30617.615   ,\n",
       "         30617.615   , 30617.615   ],\n",
       "        [30581.475   , 30580.365   , 30579.422   , ..., 30584.951   ,\n",
       "         30583.752   , 30582.557   ],\n",
       "        [30549.072   , 30546.88    , 30544.803   , ..., 30556.213   ,\n",
       "         30553.752   , 30551.377   ],\n",
       "        ...,\n",
       "        [29187.924   , 29186.947   , 29186.088   , ..., 29192.057   ,\n",
       "         29190.506   , 29189.143   ],\n",
       "        [29189.156   , 29188.596   , 29188.053   , ..., 29191.25    ,\n",
       "         29190.502   , 29189.81    ],\n",
       "        [29205.365   , 29205.365   , 29205.365   , ..., 29205.365   ,\n",
       "         29205.365   , 29205.365   ]]], dtype=float32)</pre></div></div></li><li class='xr-section-item'><input id='section-33f8e86c-400e-4f47-8ce7-0f85ccf406b2' class='xr-section-summary-in' type='checkbox'  checked><label for='section-33f8e86c-400e-4f47-8ce7-0f85ccf406b2' class='xr-section-summary' >Coordinates: <span>(3)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>level</span></div><div class='xr-var-dims'>(level)</div><div class='xr-var-dtype'>float32</div><div class='xr-var-preview xr-preview'>1e+03 925.0 850.0 ... 20.0 10.0</div><input id='attrs-9dd3071e-4839-42de-9e14-901494e9af1b' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-9dd3071e-4839-42de-9e14-901494e9af1b' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-aef71dd7-5089-4ade-b146-3e7967ed107b' class='xr-var-data-in' type='checkbox'><label for='data-aef71dd7-5089-4ade-b146-3e7967ed107b' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>units :</span></dt><dd>millibar</dd><dt><span>long_name :</span></dt><dd>Level</dd><dt><span>positive :</span></dt><dd>down</dd><dt><span>GRIB_id :</span></dt><dd>100</dd><dt><span>GRIB_name :</span></dt><dd>hPa</dd><dt><span>actual_range :</span></dt><dd>[1000.   10.]</dd><dt><span>axis :</span></dt><dd>Z</dd></dl></div><div class='xr-var-data'><pre>array([1000.,  925.,  850.,  700.,  600.,  500.,  400.,  300.,  250.,  200.,\n",
       "        150.,  100.,   70.,   50.,   30.,   20.,   10.], dtype=float32)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>lat</span></div><div class='xr-var-dims'>(lat)</div><div class='xr-var-dtype'>float32</div><div class='xr-var-preview xr-preview'>90.0 87.5 85.0 ... -87.5 -90.0</div><input id='attrs-fd70b177-0bf8-40a0-81f9-02d2b33e402e' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-fd70b177-0bf8-40a0-81f9-02d2b33e402e' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-82d348c2-55fb-445b-b787-728d7940a3db' class='xr-var-data-in' type='checkbox'><label for='data-82d348c2-55fb-445b-b787-728d7940a3db' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>units :</span></dt><dd>degrees_north</dd><dt><span>actual_range :</span></dt><dd>[ 90. -90.]</dd><dt><span>long_name :</span></dt><dd>Latitude</dd><dt><span>standard_name :</span></dt><dd>latitude</dd><dt><span>axis :</span></dt><dd>Y</dd></dl></div><div class='xr-var-data'><pre>array([ 90. ,  87.5,  85. ,  82.5,  80. ,  77.5,  75. ,  72.5,  70. ,  67.5,\n",
       "        65. ,  62.5,  60. ,  57.5,  55. ,  52.5,  50. ,  47.5,  45. ,  42.5,\n",
       "        40. ,  37.5,  35. ,  32.5,  30. ,  27.5,  25. ,  22.5,  20. ,  17.5,\n",
       "        15. ,  12.5,  10. ,   7.5,   5. ,   2.5,   0. ,  -2.5,  -5. ,  -7.5,\n",
       "       -10. , -12.5, -15. , -17.5, -20. , -22.5, -25. , -27.5, -30. , -32.5,\n",
       "       -35. , -37.5, -40. , -42.5, -45. , -47.5, -50. , -52.5, -55. , -57.5,\n",
       "       -60. , -62.5, -65. , -67.5, -70. , -72.5, -75. , -77.5, -80. , -82.5,\n",
       "       -85. , -87.5, -90. ], dtype=float32)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>lon</span></div><div class='xr-var-dims'>(lon)</div><div class='xr-var-dtype'>float32</div><div class='xr-var-preview xr-preview'>0.0 2.5 5.0 ... 352.5 355.0 357.5</div><input id='attrs-48bb6e25-6f4e-424d-9aea-f8f26256f034' class='xr-var-attrs-in' type='checkbox' ><label for='attrs-48bb6e25-6f4e-424d-9aea-f8f26256f034' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-01309df2-a753-4e14-879f-65c67d46d5ba' class='xr-var-data-in' type='checkbox'><label for='data-01309df2-a753-4e14-879f-65c67d46d5ba' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'><dt><span>units :</span></dt><dd>degrees_east</dd><dt><span>long_name :</span></dt><dd>Longitude</dd><dt><span>actual_range :</span></dt><dd>[  0.  357.5]</dd><dt><span>standard_name :</span></dt><dd>longitude</dd><dt><span>axis :</span></dt><dd>X</dd></dl></div><div class='xr-var-data'><pre>array([  0. ,   2.5,   5. ,   7.5,  10. ,  12.5,  15. ,  17.5,  20. ,  22.5,\n",
       "        25. ,  27.5,  30. ,  32.5,  35. ,  37.5,  40. ,  42.5,  45. ,  47.5,\n",
       "        50. ,  52.5,  55. ,  57.5,  60. ,  62.5,  65. ,  67.5,  70. ,  72.5,\n",
       "        75. ,  77.5,  80. ,  82.5,  85. ,  87.5,  90. ,  92.5,  95. ,  97.5,\n",
       "       100. , 102.5, 105. , 107.5, 110. , 112.5, 115. , 117.5, 120. , 122.5,\n",
       "       125. , 127.5, 130. , 132.5, 135. , 137.5, 140. , 142.5, 145. , 147.5,\n",
       "       150. , 152.5, 155. , 157.5, 160. , 162.5, 165. , 167.5, 170. , 172.5,\n",
       "       175. , 177.5, 180. , 182.5, 185. , 187.5, 190. , 192.5, 195. , 197.5,\n",
       "       200. , 202.5, 205. , 207.5, 210. , 212.5, 215. , 217.5, 220. , 222.5,\n",
       "       225. , 227.5, 230. , 232.5, 235. , 237.5, 240. , 242.5, 245. , 247.5,\n",
       "       250. , 252.5, 255. , 257.5, 260. , 262.5, 265. , 267.5, 270. , 272.5,\n",
       "       275. , 277.5, 280. , 282.5, 285. , 287.5, 290. , 292.5, 295. , 297.5,\n",
       "       300. , 302.5, 305. , 307.5, 310. , 312.5, 315. , 317.5, 320. , 322.5,\n",
       "       325. , 327.5, 330. , 332.5, 335. , 337.5, 340. , 342.5, 345. , 347.5,\n",
       "       350. , 352.5, 355. , 357.5], dtype=float32)</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-89ae2483-65b7-4a15-ab8b-07a0130e33ed' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-89ae2483-65b7-4a15-ab8b-07a0130e33ed' class='xr-section-summary'  title='Expand/collapse section'>Attributes: <span>(0)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><dl class='xr-attrs'></dl></div></li></ul></div></div>"
      ],
      "text/plain": [
       "<xarray.DataArray 'hgt' (level: 17, lat: 73, lon: 144)>\n",
       "array([[[  125.18029 ,   125.18029 ,   125.18029 , ...,   125.18029 ,\n",
       "           125.18029 ,   125.18029 ],\n",
       "        [  124.14675 ,   123.99787 ,   123.81977 , ...,   124.7157  ,\n",
       "           124.50152 ,   124.34173 ],\n",
       "        [  123.541084,   123.09136 ,   122.68626 , ...,   125.17368 ,\n",
       "           124.57856 ,   124.0277  ],\n",
       "        ...,\n",
       "        [  164.80504 ,   171.08635 ,   176.92877 , ...,   143.55917 ,\n",
       "           151.0109  ,   158.10338 ],\n",
       "        [  159.59138 ,   162.39555 ,   165.04416 , ...,   150.40852 ,\n",
       "           153.57771 ,   156.6823  ],\n",
       "        [  122.65192 ,   122.65192 ,   122.65192 , ...,   122.65192 ,\n",
       "           122.65192 ,   122.65192 ]],\n",
       "\n",
       "       [[  723.87524 ,   723.87524 ,   723.87524 , ...,   723.87524 ,\n",
       "           723.87524 ,   723.87524 ],\n",
       "        [  721.89105 ,   721.7818  ,   721.6912  , ...,   722.2271  ,\n",
       "           722.1367  ,   722.019   ],\n",
       "        [  721.1213  ,   720.8413  ,   720.64215 , ...,   722.0701  ,\n",
       "           721.71173 ,   721.3724  ],\n",
       "...\n",
       "        [24831.195   , 24829.828   , 24828.44    , ..., 24835.428   ,\n",
       "         24833.986   , 24832.617   ],\n",
       "        [24826.39    , 24825.748   , 24825.111   , ..., 24828.5     ,\n",
       "         24827.771   , 24827.086   ],\n",
       "        [24834.43    , 24834.43    , 24834.43    , ..., 24834.43    ,\n",
       "         24834.43    , 24834.43    ]],\n",
       "\n",
       "       [[30617.615   , 30617.615   , 30617.615   , ..., 30617.615   ,\n",
       "         30617.615   , 30617.615   ],\n",
       "        [30581.475   , 30580.365   , 30579.422   , ..., 30584.951   ,\n",
       "         30583.752   , 30582.557   ],\n",
       "        [30549.072   , 30546.88    , 30544.803   , ..., 30556.213   ,\n",
       "         30553.752   , 30551.377   ],\n",
       "        ...,\n",
       "        [29187.924   , 29186.947   , 29186.088   , ..., 29192.057   ,\n",
       "         29190.506   , 29189.143   ],\n",
       "        [29189.156   , 29188.596   , 29188.053   , ..., 29191.25    ,\n",
       "         29190.502   , 29189.81    ],\n",
       "        [29205.365   , 29205.365   , 29205.365   , ..., 29205.365   ,\n",
       "         29205.365   , 29205.365   ]]], dtype=float32)\n",
       "Coordinates:\n",
       "  * level    (level) float32 1e+03 925.0 850.0 700.0 ... 50.0 30.0 20.0 10.0\n",
       "  * lat      (lat) float32 90.0 87.5 85.0 82.5 80.0 ... -82.5 -85.0 -87.5 -90.0\n",
       "  * lon      (lon) float32 0.0 2.5 5.0 7.5 10.0 ... 350.0 352.5 355.0 357.5"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 当然你也可以通过这样去实现上述的操作，不过就比较麻烦，平时求平均值用下面这个比较多\n",
    "hgt1=ds['hgt'].loc['2010',:,:,:]\n",
    "hgt1.mean(dim='time')"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "cc5f70855ac006f3de45a3cc3b9e7d8d53845e50458809cb162b0174266dec97"
  },
  "kernelspec": {
   "display_name": "Python 3.9.10 ('base')",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.10"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
